// pages/home/home.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {

    },

    /**
     * 组件的初始数据
     */
    data: {

    },

    /**
     * 组件的方法列表
     */
    methods: {
        getInfo() {
            wx.request({
                url: 'https://i.maoyan.com/api/mmdb/movie/v3/list/hot.json?ct=北京&ci=1&channelId=4',
                method: 'GET',
                data: {
                    name: 'zs',
                    age: 20
                },
                success: (res) => {
                    console.log(res);
                }
            })
        },
        postInfo() {
            wx.request({
                url: 'https://i.maoyan.com/asgard/api/mmdb/open/tg/pre.json?utm_source=Baidu&channel=Baidu__&refer_page_id=c_dmLad&redirectUrl=meituanmovie%3A%2F%2Fwww.meituan.com%2Fmovie%3Fid%3D1308364%26nm%3D%25E6%259A%2597%25E6%2581%258B%25C2%25B7%25E6%25A9%2598%25E7%2594%259F%25E6%25B7%25AE%25E5%258D%2597',
                method: 'POST',
                data: {
                    utm_source: 'Baidu',
                    channel: 'Baidu__',
                    refer_page_id: 'c_dmLad',
                    redirectUrl: 'meituanmovie://www.meituan.com/movie?id=1308364&nm=%E6%9A%97%E6%81%8B%C2%B7%E6%A9%98%E7%94%9F%E6%B7%AE%E5%8D%97'
                },
                success: (res) => {
                    console.log(res);
                }
            })
        },
        //通过编程式导航跳转到 tabBar 页面
        gotoMessage() {
            wx.switchTab({
                url: '/pages/message/message',
            })
        },
        gotoInfo(){
            wx.navigateTo({
              url: '/pages/info/info',
            })
        }
    },
    lifetimes: {
        attached: function () {
            // 在组件实例进入页面节点树时执行
            this.getInfo();
            console.log('get执行完毕');
            this.postInfo();
            console.log('post执行完毕');
        },
        detached: function () {
            // 在组件实例被从页面节点树移除时执行
        },
    }
})